using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Zoo.Controller;
using Zoo;
using Zoo.View;

public partial class UserControls_LocalizationControl : ControlBase, ILocalizationControlView
{
    private LocalizationControlController controller;

    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        IZooModel model = new ZooModel();
        controller = new LocalizationControlController(this,model);

    }

    protected void Page_Load(object sender, EventArgs e)
    {
        controller.Initialize();
        Page.DataBind();
    }

    #region ILocalizationControlView Members

    public ListItemCollection CountryValues
    {
        get
        {
            return DdlCountry.Items;
        }
        set
        {
            Utility.CopyListItem(value, DdlCountry.Items);
        }
    }

    public ListItemCollection RegionValues
    {
        get
        {
            return DdlRegion.Items;
        }
        set
        {
            Utility.CopyListItem(value, DdlRegion.Items);
        }
    }

    public event EventHandler CountrySelectedIndex_Change;

    public int CountryID
    {
        get
        {
            return Int32.Parse(DdlCountry.SelectedValue);
        }
        set
        {
            Utility.SetSelectedItem(DdlCountry, value.ToString());
        }
    }

    public int RegionID
    {
        get
        {
            return Int32.Parse(DdlRegion.SelectedValue);
        }
        set
        {
            Utility.SetSelectedItem(DdlRegion, value.ToString());
        }
    }


    #endregion

    protected virtual void OnCountrySelectedIndex_Change(object sender, EventArgs e)
    {
        if (CountrySelectedIndex_Change != null)
            CountrySelectedIndex_Change(this, e);
    }

    protected void DdlCountry_SelectedIndexChanged(object sender, EventArgs e)
    {
        OnCountrySelectedIndex_Change(sender, e);
    }

}
